package com.shop.common.enums;

/**
 * 分类类型
 */
public enum CategoryTypeEnum {

    COURSE(1, "课程分类"),
    QUESTION(2, "试题分类");

    /**
     * 构造方法
     */
    private final int code;
    private final String msg;
    CategoryTypeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 获取状态码
     *
     * @author fzr
     * @return Long
     */
    public int getCode() {
        return this.code;
    }

    /**
     * 获取提示
     *
     * @author fzr
     * @return String
     */
    public String getMsg() {
        return this.msg;
    }

    /**
     * 根据编码获取Msg
     *
     * @author fzr
     * @param code 类型
     * @return String
     */
    public static String getMsgByCode(Integer code){
        for(CategoryTypeEnum enumItem: CategoryTypeEnum.values()) {
            if (enumItem.getCode() == code) {
                return enumItem.getMsg();
            }
        }
        return null;
    }

}
